In [1]:
import numpy as np
%pylab
from numpy.fft import fft, fftshift


Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib

In [2]:
n = 1.5
l = 780e-9
k = 2*pi/l
x = linspace(-300,300,600)*20e-6
L = 5000*l
s = 780e-9/10.0
m = k*(n-1)*s

#fieldout = np.exp(1j*m/2.0*sin(2*pi*x/L)) # a sinusoidal phase variation
noise = array([np.random.ranf() for i in x])
fieldout = np.exp(1j*m/2.0*noise)

In [3]:
plot(fftfreq(600,20e-6),np.abs(fft(fieldout)),".-")


Out[3]:
[<matplotlib.lines.Line2D at 0x7f37e2f4e710>]

In [4]:
L


Out[4]:
0.0039000000000000003

4 mm grating wavelength... with 1/10 wavelength variation. This is essentially the limit to the flatness of any glass optic.


In [5]:
from scipy.signal import spline_filter

In [6]:
smoothed = spline_filter(noise.reshape((600,1)),1)

In [7]:
plot(smoothed)


Out[7]:
[<matplotlib.lines.Line2D at 0x7f37c632e2e8>]

In [8]:
plot(noise)


Out[8]:
[<matplotlib.lines.Line2D at 0x7f37c6242e10>]

In [ ]: